home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C- WorkDisk V.adf / image / imagebs2.c < prev    next >
C/C++ Source or Header  |  1987-02-15  |  4KB  |  190 lines

  1. #include "exec/types.h"
  2. #include "intuition/intuition.h"
  3.  
  4. struct IntuitionBase *IntuitionBase;
  5. struct Window *NoBorder;
  6. struct GfxBase *GfxBase;
  7. struct IntuiMessage *mesg;
  8. struct RastPort *r;
  9. struct ViewPort *vp;
  10. struct Screen *Scrn;
  11.  
  12. USHORT bs1smallData[] =
  13. {
  14. 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  15. 0x7CF0,0x3E70,0x0000,0xE61F,0xE73D,0xFC00,
  16. 0x7CF8,0xFF30,0x0001,0xE79F,0xF33C,0x1C00,
  17. 0x7CFC,0xFF90,0x0003,0xE78F,0xF93C,0x3000,
  18. 0x7CF0,0x7FC0,0x0003,0xE787,0xFC3D,0xF000,
  19. 0x7CF8,0x3FE0,0x0003,0xE793,0xFE3C,0x7000,
  20. 0x7CFC,0x9FF0,0x0001,0xE799,0xFF3C,0x0C00,
  21. 0x7CF8,0xCFE0,0x0000,0xE71C,0xFF3C,0x7C00,
  22. 0x0000,0x0000,0x0000,0x0000,0x0000,0x01E1
  23.  
  24. };
  25.  
  26. struct Image bs1small =
  27. {
  28. 0,0,          /* LeftEdge, TopEdge */
  29. 87,9,1,     /* Width, Height, Depth */
  30. &bs1smallData[0],
  31. 1,0,       /* PlanePick, PlaneOnOff */
  32. NULL        /* Pointer to next Image */
  33. };
  34.  
  35.  
  36.  
  37. #define INTUITION_REV 0
  38. #define GRAPHICS_REV 0
  39. main()
  40. {
  41.  ULONG flags,mclass;
  42.  SHORT x,y,w,h,d;
  43.  USHORT mode;
  44.  UBYTE *name,c0,c1;
  45.  VOID OpenALL();
  46.  double ran(), rannr;
  47.  OpenALL();
  48.  
  49.  
  50.  /* ======Open een lores custom screen====== */
  51.  
  52.  y=0;
  53.  w=320;
  54.  h=200;
  55.  d=5; /* max 32 colors ! */
  56.  c0=0x00;
  57.  c1=0x01;
  58.  mode=NULL;
  59.  
  60.  Scrn=(struct Screen *)
  61.          make_screen(y,w,h,d,c0,c1,mode,NULL);
  62.  
  63.  /* ======open een borderless window ====== */
  64.  
  65.  x=y=0;
  66.  w=320;
  67.  h=200;
  68.  flags=ACTIVATE|NOCAREREFRESH|BORDERLESS|GIMMEZEROZERO;
  69.  NoBorder=(struct Window *)
  70.              make_window(x,y,w,h,NULL,flags,Scrn);
  71.  
  72.  /* ======geen screentitel====== */
  73.  
  74.  ClearMenuStrip(NoBorder);
  75.  
  76.  
  77.   r=NoBorder->RPort;
  78.  vp=ViewPortAddress(NoBorder);
  79.  
  80. for(x=0;x<32;x++) SetRGB4(r,x,x%16,x%16,(15-x)%16);
  81.  
  82. for(;;)
  83. {
  84.   x = (LONG) ( (rannr=ran() ) * (320.0-87.0) );
  85.   y = (LONG) ( (rannr=ran() ) * (199.0-9.0)  );
  86.  
  87.   bs1small.Height = 1;
  88.  
  89.   for(h=1;h<=9;h++)
  90.   {
  91.    bs1small.ImageData = &bs1smallData[(h-1)*6];
  92.    DrawImage(r,&bs1small,x,y+h);
  93.   }
  94.   
  95.   Delay(1);
  96.  
  97.   if( (mesg=(struct IntuiMessage *) GetMsg(NoBorder->UserPort)) != NULL)
  98.   { 
  99.    ReplyMsg(mesg);
  100.    break;
  101.   }
  102. }
  103.  
  104.  while( (mesg=(struct IntuiMessage *) GetMsg(NoBorder->UserPort)) != NULL)
  105.   ReplyMsg(mesg);
  106.  
  107.      CloseWindow(NoBorder);
  108.      CloseScreen(Scrn);
  109.      CloseLibrary(GfxBase);
  110.  
  111. }
  112.  /*========================================================================*/
  113.  
  114.  VOID OpenALL()
  115.  {
  116.  /* ======open Intuition====== */
  117.  
  118.  IntuitionBase=(struct IntuitionBase *)
  119.             OpenLibrary("intuition.library",INTUITION_REV);
  120.  
  121.  if(IntuitionBase==NULL)
  122.    exit(FALSE);
  123.  
  124.  /* ======open the Graphics Library====== */
  125.  
  126.  GfxBase=(struct GfxBase *)
  127.            OpenLibrary("graphics.library",GRAPHICS_REV);
  128.  
  129.  if(GfxBase==NULL)
  130.    exit(FALSE);
  131.  }
  132. make_window(x,y,w,h,name,flags,screen)
  133. SHORT x,y,w,h;
  134. UBYTE *name;
  135. ULONG flags;
  136. struct Screen *screen;
  137.  
  138. {
  139.  struct NewWindow NewWindow;
  140.  
  141.  NewWindow.LeftEdge = x;
  142.  NewWindow.TopEdge = y;
  143.  NewWindow.Width = w;
  144.  NewWindow.Height = h;
  145.  NewWindow.DetailPen = -1;
  146.  NewWindow.BlockPen = -1;
  147.  NewWindow.Title = name;
  148.  NewWindow.Flags = flags;
  149.  NewWindow.IDCMPFlags = MOUSEBUTTONS;
  150.  NewWindow.Type = CUSTOMSCREEN;
  151.  NewWindow.FirstGadget = NULL;
  152.  NewWindow.CheckMark = NULL;
  153.  NewWindow.Screen = screen;
  154.  NewWindow.BitMap = NULL;
  155.  NewWindow.MinWidth = 0;
  156.  NewWindow.MinHeight = 0;
  157.  NewWindow.MaxWidth = 0;
  158.  NewWindow.MaxHeight = 0;
  159.  
  160.  return(OpenWindow(&NewWindow));
  161.  
  162. }
  163.  
  164.  
  165. make_screen(y,w,h,d,color0,color1,mode,name)
  166. SHORT y,w,h,d;
  167. UBYTE color0,color1,*name;
  168. USHORT mode;
  169. {
  170.  struct NewScreen NewScreen;
  171.  
  172.  NewScreen.LeftEdge = 0;
  173.  NewScreen.TopEdge = y;
  174.  NewScreen.Width = w;
  175.  NewScreen.Height = h;
  176.  NewScreen.Depth = d;
  177.  NewScreen.DetailPen = color0;
  178.  NewScreen.BlockPen = color1;
  179.  NewScreen.ViewModes = mode;
  180.  NewScreen.Type = CUSTOMSCREEN;
  181.  NewScreen.Font = NULL;
  182.  NewScreen.DefaultTitle = name;
  183.  NewScreen.Gadgets = NULL;
  184.  NewScreen.CustomBitMap = NULL;
  185.  
  186.  return(OpenScreen(&NewScreen));
  187. }
  188.  
  189.  
  190.